<template>
{{#if ctrl.psSysPFPlugin}}
  {{> @macro/plugins/widget/widget-use.hbs appPlugin=ctrl.psSysPFPlugin}}
{{else}}
  <div :class="classNames" {{#or ctrl.width ctrl.height}} style="{{#if ctrl.width}}width: {{ctrl.width}}px;{{/if}}{{#if ctrl.height}}height: {{ctrl.height}}px;{{/if}}"{{/or}}>
    <AppSheet :name="model.codeName" :config="store.data" :enableDesign="store.enableDesign" v-if="store.isLoaded"></AppSheet>
    <template v-else>
      <AppEmptyDataTip></AppEmptyDataTip>
    </template>
  </div>
{{/if}}
</template>
<script setup lang="ts">
// 基于template/src/widgets/\{{appEntities}}/\{{ctrls@REPORTPANEL}}-report-panel/\{{spinalCase ctrl.codeName}}-report-panel.vue.hbs生成
import { AppSheet } from '@components/widgets/sheet';
{{> @macro/plugins/widget/widget-import.hbs ctrl=ctrl}}
{{importPlugin 'report-panel' ctrl}}
import { IContext, IParam, IViewLogicInput } from "@/core";
import { ReportPanelActionType, ICtrlDataAction, IReportPanelAbility, IReportPanelControllerParams, IReportPanelStore, ReportPanelController, ILoadingHelper, LoadingHelper, createUUID, IViewCtx } from "@/core";
import { useNavParamsBind, useEventBind, handleActionClick, getCtrlClassNames } from '@/hooks/use-ctrl';
import { {{pascalCase ctrl.name}}ControlVO } from './{{spinalCase ctrl.codeName}}-report-panel-vo';
import { model } from "./{{spinalCase ctrl.codeName}}-report-panel-model";
import ReportPanelService from "@/core/modules/ctrl-service/report-panel-service";
{{> @macro/widgets/ctrl/ctrl-props.hbs
    props="openView?: Function;
    newView?: Function;
    actions: ICtrlDataAction;
    "
}}

{{> @macro/common/emit.hbs name="ctrl" actionType="ReportPanelActionType" ability="IReportPanelAbility"}}

//  部件样式名
const classNames = computed(() => {
  const names = getCtrlClassNames(model, props);
  return names;
});

const controlID = createUUID();
const attrs = useAttrs();
const ctrlService = new ReportPanelService<{{pascalCase ctrl.name}}ControlVO>({{pascalCase ctrl.name}}ControlVO, model.entityCodeName,attrs);
const params: IReportPanelControllerParams<ReportPanelActionType, IReportPanelAbility> = {
  name: props.name,
  model,
  customParams:attrs,
  evt,
  controlID,
  pLoadingHelper: props.pLoadingHelper,
  actions: props.actions,
  ctrlService: ctrlService,
  openView: props.openView,
  newView: props.newView,
  closeView: props.closeView,
  pViewCtx: props.pViewCtx,
  handler: (data: IReportPanelStore) => { return reactive(data) }
};
//  报表面板控制器
const controller = new ReportPanelController(params);
useNavParamsBind(controller, props);
const store: IReportPanelStore = controller.getStore();

onMounted(() => {
  controller.ctrlMounted();
});
onUnmounted(() => {
  controller.ctrlDestroy();
})
</script>
